package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.common.AreaControlVO;
import com.jwsoft.manager.common.vo.eduSocialSecurity.EduSocialSecurityKeyVO;
import com.jwsoft.manager.common.vo.eduSocialSecurity.EduSocialSecurityQueryVO;
import com.jwsoft.manager.common.vo.eduSocialSecurity.EduSocialSecurityVO;
import com.jwsoft.manager.common.vo.individuation.CbSaveVO;
import com.jwsoft.manager.core.integration.EduSocialSecurityIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 参保记录表网关
 *
 * @author wangtao
 * @since 2022-12-28
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "参保记录表", description = "参保记录表")
public class EduSocialSecurityController {

    @Autowired
    public EduSocialSecurityIntegration eduSocialSecurityIntegration;

    @Operation(summary = "参保记录表分页查询",description = "参保记录表分页查询")
    @PostMapping(value = "/EduSocialSecurity0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduSocialSecurityVO>> getList(@RequestBody @Validated EduSocialSecurityQueryVO vo) {
        return AppResponse.successData(eduSocialSecurityIntegration.getList(vo));
    }

    @Operation(summary = "参保记录表根据主键查询详情",description = "参保记录表根据主键查询详情")
    @PostMapping(value = "/EduSocialSecurity0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSocialSecurityVO> getById(@RequestBody @Validated EduSocialSecurityKeyVO vo) {
        return AppResponse.successData(eduSocialSecurityIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "参保记录表新增",description = "参保记录表新增")
    @PostMapping(value = "/EduSocialSecurity0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSocialSecurityVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduSocialSecurityVO vo) {
        return AppResponse.successData(eduSocialSecurityIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "参保记录表修改",description = "参保记录表修改")
    @PostMapping(value = "/EduSocialSecurity0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSocialSecurityVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduSocialSecurityVO vo) {
        return AppResponse.successData(eduSocialSecurityIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "参保记录表删除",description = "参保记录表删除")
    @PostMapping(value = "/EduSocialSecurity0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduSocialSecurityKeyVO vo) {
        eduSocialSecurityIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }
    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "根据身份证单个获取参保信息并保存",description = "根据身份证单个获取参保信息并保存")
    @PostMapping(value = "/EduSocialSecurity0007", produces = "application/json;charset=UTF-8")
    public AppResponse getSocialSecurity(@RequestBody @Validated CbSaveVO vo) {
        return AppResponse.successData(eduSocialSecurityIntegration.getSocialSecurityAndSave(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "家长端获取参保信息并保存",description = "家长端获取参保信息并保存")
    @PostMapping(value = "/EduSocialSecurity0008", produces = "application/json;charset=UTF-8")
    public AppResponse getAppSocialSecurityAndSave(@RequestBody @Validated CbSaveVO vo) {
        return AppResponse.successData(eduSocialSecurityIntegration.getAppSocialSecurityAndSave(vo));
    }
    @Operation(summary = "家长端当年适龄子女获取参保信息",description = "家长端当年适龄子女获取参保信息")
    @PostMapping(value = "/EduSocialSecurity0009", produces = "application/json;charset=UTF-8")
    public AppResponse<List<EduSocialSecurityVO>> getAppSocialSecurityList(@RequestBody @Validated AreaControlVO vo) {
        return AppResponse.successData(eduSocialSecurityIntegration.getAppSocialSecurityList(vo));
    }
}
